/**
 * 功能描述
 */
define(function (require, exports, module) {
    //引入视图基类
    var ELView = require("elview");
    var aw = require("ajaxwrapper");
    var store = require("store");

    //assets
    var template = require("./assets/tpl/destnbuilding_main.tpl");
    require("./assets/css/destnbuilding_main.css");

    //business

    //component
    var destnBuildingFormComp = require("./component/destnBuildingFormComp");
    var destnBuildingGridComp = require("./component/destnBuildingGridComp");
    var destnBuildingSubnavComp = require("./component/destnBuildingSubnavComp");

    //constant

    //handler

    //store
    var procDestnBuilding = require("./store/procDestnBuilding");

    var App = ELView.extend({
        attrs: {
            template: template
        },
        initComponent: function (params, widget) {
        	destnBuildingSubnavComp.initComponent(params, widget); 
        	destnBuildingGridComp.initComponent(params, widget); 
        	destnBuildingFormComp.initComponent(widget); 

        },
        afterInitComponent: function (params, widget) {
        	aw.ajax({
				url : "api/servicepoint/operableservicepoints",
				data : {
					fetchProperties:"pkServicePoint,name"
				},
				success:function(data){
					widget.get("subnav").setData("servicePoint",data);
			        widget.get("grid").refresh();
					widget.get("form").load("orgBuilding", {
					params :{
							"servicePoint":data.pkServicePoint,
							fetchProperties :"pkOrgBuilding,name,floors,roomCount," +
									"pkDestination,name"
						}
					});
					widget.get("grid").refresh();
					widget.get("form").load("orgBuilding", {
						params :{
							fetchProperties :"pkOrgBuilding,name,floors,roomCount"
						}
					});
				}
		});
        }
   });

    module.exports = App;
});

